package com.sleep.psy.external_server.business.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sleep.psy.external_server.business.sys.entity.SysProjectConfig;
import com.sleep.psy.external_server.business.sys.mapper.SysProjectConfigMapper;
import com.sleep.psy.external_server.business.sys.service.SysProjectConfigService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sleep.psy.external_server.constants.MySqlConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 项目配置表 服务实现类
 * </p>
 *
 * @author wenliguo
 * @since 2025-09-09
 */
@Service
public class SysProjectConfigServiceImpl extends ServiceImpl<SysProjectConfigMapper, SysProjectConfig> implements SysProjectConfigService {

    @Autowired
    private SysProjectConfigMapper projectConfigMapper;

    /**
     * 通过key查询有效配置
     * @author wenliguo
     * @date 2025/9/9 16:05
     * @param key key
     * @return com.sleep.psy.external_server.business.sys.entity.SysProjectConfig
     */
    @Override
    public SysProjectConfig selectByKey(String key) {
        QueryWrapper<SysProjectConfig> wrapper = new QueryWrapper<>();
        wrapper.eq("config_key", key)
                .eq("status", MySqlConstant.STATUS_1);
        return projectConfigMapper.selectOne(wrapper);
    }
}
